﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class DwExportParams : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public DwExportParams(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(DwExportParams obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~DwExportParams()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_DwExportParams(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		private static uint[] UnMarshalPalette(IntPtr p)
		{
			if (p == IntPtr.Zero)
			{
				return null;
			}
			uint[] array = new uint[256];
			for (int i = 0; i < 256; i++)
			{
				array[i] = (uint)Marshal.ReadInt32(p, i * 4);
			}
			return array;
		}

		private static IntPtr MarshalPalette(uint[] p)
		{
			if (p == null)
			{
				return IntPtr.Zero;
			}
			if (p.Length != 256)
			{
				throw new Exception("MarshalPalette: palette size must be 256");
			}
			IntPtr intPtr = Marshal.AllocCoTaskMem(1024);
			for (int i = 0; i < 256; i++)
			{
				Marshal.WriteInt32(intPtr, i * 4, (int)p[i]);
			}
			return intPtr;
		}

		public uint[] Palette
		{
			get
			{
				return DwExportParams.UnMarshalPalette(GlobalsPINVOKE.DwExportParams_getPalette(this.swigCPtr));
			}
			set
			{
				IntPtr intPtr = DwExportParams.MarshalPalette(value);
				GlobalsPINVOKE.DwExportParams_setPalette(this.swigCPtr, intPtr);
				Marshal.FreeCoTaskMem(intPtr);
			}
		}

		public int getPagesNum()
		{
			int result = GlobalsPINVOKE.DwExportParams_getPagesNum(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public DwfPageData getPageData(int index)
		{
			IntPtr cPtr = GlobalsPINVOKE.DwExportParams_getPageData(this.swigCPtr, index);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new DwfPageData(cPtr, false);
		}

		public void appendPageData(DwfPageData page)
		{
			GlobalsPINVOKE.DwExportParams_appendPageData(this.swigCPtr, DwfPageData.getCPtr(page));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public DwExportParams() : this(GlobalsPINVOKE.new_DwExportParams(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdRxObject pDb
		{
			get
			{
				IntPtr intPtr = GlobalsPINVOKE.DwExportParams_pDb_get(this.swigCPtr);
				OdRxObject result = (intPtr == IntPtr.Zero) ? null : new OdRxObject(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_pDb_set(this.swigCPtr, OdRxObject.getCPtr(value));
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public string sDwfFileName
		{
			get
			{
				string result = GlobalsPINVOKE.DwExportParams_sDwfFileName_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_sDwfFileName_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public int xSize
		{
			get
			{
				int result = GlobalsPINVOKE.DwExportParams_xSize_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_xSize_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public int ySize
		{
			get
			{
				int result = GlobalsPINVOKE.DwExportParams_ySize_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_ySize_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public DW_FORMAT Format
		{
			get
			{
				DW_FORMAT result = (DW_FORMAT)GlobalsPINVOKE.DwExportParams_Format_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_Format_set(this.swigCPtr, (int)value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public int Version
		{
			get
			{
				int result = GlobalsPINVOKE.DwExportParams_Version_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_Version_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public uint background
		{
			get
			{
				uint result = GlobalsPINVOKE.DwExportParams_background_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_background_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bExportInvisibleLayers
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bExportInvisibleLayers_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bExportInvisibleLayers_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bForceInitialViewToExtents
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bForceInitialViewToExtents_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bForceInitialViewToExtents_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bSkipLayerInfo
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bSkipLayerInfo_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bSkipLayerInfo_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bSkipNamedViewsInfo
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bSkipNamedViewsInfo_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bSkipNamedViewsInfo_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bInkedArea
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bInkedArea_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bInkedArea_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bColorMapOptimize
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bColorMapOptimize_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bColorMapOptimize_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bRGBToJpeg
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bRGBToJpeg_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bRGBToJpeg_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bUseHLR
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bUseHLR_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bUseHLR_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public uint nMaxPointsInPolygon
		{
			get
			{
				uint result = GlobalsPINVOKE.DwExportParams_nMaxPointsInPolygon_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_nMaxPointsInPolygon_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public ushort nMaxRasterResolution
		{
			get
			{
				ushort result = GlobalsPINVOKE.DwExportParams_nMaxRasterResolution_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_nMaxRasterResolution_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public string sPassword
		{
			get
			{
				string result = GlobalsPINVOKE.DwExportParams_sPassword_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_sPassword_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public string sPublisher
		{
			get
			{
				string result = GlobalsPINVOKE.DwExportParams_sPublisher_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_sPublisher_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public string sWideComments
		{
			get
			{
				string result = GlobalsPINVOKE.DwExportParams_sWideComments_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_sWideComments_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public string sSourceProductName
		{
			get
			{
				string result = GlobalsPINVOKE.DwExportParams_sSourceProductName_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_sSourceProductName_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bExportInvisibleText
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bExportInvisibleText_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bExportInvisibleText_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public bool bEmbedAllFonts
		{
			get
			{
				bool result = GlobalsPINVOKE.DwExportParams_bEmbedAllFonts_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.DwExportParams_bEmbedAllFonts_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
